// OrderDetail类
public class OrderDetail {
    private int quantity;
    private List<Product> products = new ArrayList<>();

    public OrderDetail(int quantity) {
        this.quantity = quantity;
    }

    public void addProduct(Product product) {
        products.add(product);
    }

    public float calculateSubTotal() {
        float subTotal = 0;
        for (Product product : products) {
            subTotal += product.getPriceForQuantity(quantity);
        }
        return subTotal;
    }

    public float calculateWeight() {
        float totalWeight = 0;
        for (Product product : products) {
            totalWeight += product.getWeight() * quantity;
        }
        return totalWeight;
    }
}
